<template>
    <el-popconfirm
        title="确认是否导出？"
        @confirm="exportFun"
        trigger="click"
        placement="top"
        class="di"
        cancel-button-type='info'
    >
        <el-button slot="reference" type="primary" size="small"><i class="el-icon-position"></i> 导出</el-button>
    </el-popconfirm>
</template>

<script>
export default {
    props: {
        exportData: {
            type: Object,
            default: () => {
                return {
                    header: [],
                    column: [],
                    filename: '导出数据',
                    show: () => {
                        return false
                    },
                    data: []
                }
            }
        }
    },
    methods: {
        exportFun(){
            const { export_json_to_excel } = require('../Excel/Export2Excel');
            const data = this.exportData.data.map(v => this.exportData.column.map(j => v[j]))
            export_json_to_excel({
                header: this.exportData.header,
                data: data,
                filename: this.exportData.filename
            });
        }
    }
}
</script>